package com.ihealthway.all.interfaces.dwihealth;

import com.ihealthway.all.interfaces.dwihealth.ws.DWSyncBaseData;
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
import org.apache.cxf.transport.servlet.CXFNonSpringServlet;
import org.nutz.ioc.Ioc;
import org.nutz.mvc.Mvcs;

import javax.servlet.ServletConfig;
import javax.xml.ws.Endpoint;

/**
 * WS main servlet
 * @author 凡梦星尘(elkan1788@gmail.com)
 */
public class WSCXFServlet extends CXFNonSpringServlet {

    @Override
    protected void loadBus(ServletConfig servletConfig) {
        super.loadBus(servletConfig);

        Bus bus = this.getBus();
        BusFactory.setDefaultBus(bus);

        Ioc ioc = Mvcs.ctx().getDefaultIoc();
        DWSyncBaseData dwSyncBaseData = ioc.get(DWSyncBaseData.class, "dWSyncBaseData");

        /*ServerFactoryBean serverFactoryBean = new ServerFactoryBean();
        // 设置服务接口类
        serverFactoryBean.setServiceClass(IDWSyncBaseData.class);
        // 服务请求路径
        serverFactoryBean.setAddress("/DWSyncBaseDataService");
        // 设置服务实现类
        serverFactoryBean.setServiceBean(dwSyncBaseData);
        serverFactoryBean.setWsdlLocation("http://127.0.0.1:8080/ws/DWSyncBaseData?wsdl");
        serverFactoryBean.setBindingId("http://schemas.xmlsoap.org/wsdl/soap12/");
        serverFactoryBean.create();*/

        Endpoint.publish("/DWSyncBaseData", dwSyncBaseData);
    }
}
